package com.zmn.plat.services.impl.orderconfig.oderstock.sp;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.orderconfig.orderstock.sp.SpWarningConfig;
import com.zmn.plat.model.entity.orderconfig.orderstock.sp.SpWarningConfigQuery;
import com.zmn.plat.persistence.interfaces.orderconfig.orderstock.sp.SpWarningConfigDao;
import com.zmn.plat.services.interfaces.orderconfig.oderstock.sp.SpWarningConfigService;

import lombok.extern.slf4j.Slf4j;

/**
 * 描述: 服务商库存预警配置基础接口实现类
 *
 * @author xiangjunming
 * @since 2020-07-22 11:23:43
 **/
@Slf4j
@Service
public class SpWarningConfigServiceImpl implements SpWarningConfigService {

    private static final String TAG = "服务商库存配置基础服务接口";

    @Resource
    private SpWarningConfigDao spWarningConfigDao;

    @Override
    public SpWarningConfig findByKey(Integer id) {
        return spWarningConfigDao.findByKey(id);
    }

    @Override
    public List<SpWarningConfig> listPageByQuery(SpWarningConfigQuery query) {
        Integer count = countByQuery(query);
        query.setTotalCount(count);
        return count > 0 ? spWarningConfigDao.listPageByQuery(query) : Collections.emptyList();
    }

    @Override
    public List<SpWarningConfig> listByQuery(SpWarningConfigQuery query) {
        return spWarningConfigDao.listByQuery(query);
    }

    @Override
    public Integer countByQuery(SpWarningConfigQuery query) {
        return spWarningConfigDao.countByQuery(query);
    }

    @Override
    public Integer updateByKey(SpWarningConfig spConfig) {
        return spWarningConfigDao.updateByKey(spConfig);
    }

    @Override
    public Integer insert(SpWarningConfig spConfig) {
        return spWarningConfigDao.insert(spConfig);
    }

    @Override
    public Integer insertBatch(List<SpWarningConfig> list) {
        return spWarningConfigDao.insertBatch(list);
    }

    @Override
    public Integer deleteByKey(Integer id) {
        return spWarningConfigDao.deleteByKey(id);
    }
}